<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:output
		encoding="utf-8"
		indent="yes"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
		omit-xml-declaration="yes"
		method="xml" />
		
	<xsl:include href="banners/show.xsl" />
	
	<xsl:param name="userGroup" select="/data/@user-group" />
	<xsl:param name="userId" select="/data/@user-id" />
	<xsl:param name="module" select="/data/@module" />
	<xsl:param name="method" select="/data/@method" />
	<xsl:param name="baseURI" select="/data/@base-uri" />
	<xsl:param name="pageTitle" select="/data/@title" />
	<xsl:param name="scode" select="/data/@scode" />
	<xsl:param name="oUser" select="document(concat('xobject://user/', $userId))/data/object" />
	
	<!-- Meta-теги стрианицы -->
	<xsl:template name="meta-head">
		<link href="{$baseURI}/favicon.ico" type="image/ico" rel="icon" />
		<!--meta http-equiv="Content-Type" content="text/html; charset=utf-8" /-->
		
		<script type="text/javascript">
			var baseURI = "<xsl:value-of select="$baseURI" />";
			var scode = "<xsl:value-of select="$scode" />";
			var userId = <xsl:value-of select="$userId" />;
			
			var GlobalSettings = {
				baseURI: "<xsl:value-of select="$baseURI" />",
				scode: "<xsl:value-of select="$scode" />",
				userId: <xsl:value-of select="$userId" />
			};
		</script>
		
		<script type="text/javascript" src="{$baseURI}/js/jQuery.js" />
		<script type="text/javascript" src="{$baseURI}/js/messages.js" />
		<script type="text/javascript" src="{$baseURI}/js/all.js" />
		<script type="text/javascript" src="{$baseURI}/js/micro.js" />
		<link rel="stylesheet" href="{$baseURI}/css/all.css" type="text/css" media="all" />
		<link rel="stylesheet" href="{$baseURI}/css/main.css" type="text/css" media="all" />
	</xsl:template>
	
	<!-- Userbar -->
	<xsl:template name="top-userbar">
		<div id="cms_messages" class="page-messages" />
			
		<div class="page-userbar">
			<xsl:choose>
				<xsl:when test="$userGroup = 'guest'">
					<form class="login" action="{$baseURI}/users/login" method="post">
						<div class="part login">
							<label for="authorization_login">логин:</label>
							<input id="authorization_login" type="text" name="login" size="16" />
						</div>
						<div class="part pass">
							<label for="authorization_pass">пароль:</label>
							<input id="authorization_pass" type="password" name="password" size="16" />
						</div>
						
						<div class="part submit">					
							<input type="submit" value="войти" />
						</div>
						
						<div class="part links">
							<a href="{$baseURI}/users/registration">регистрация</a>
							<xsl:text> | </xsl:text>
							<a href="{$baseURI}/users/forgot">забыли пароль?</a>
						</div>
					</form>
				</xsl:when>
				
				<xsl:otherwise>
					<xsl:apply-templates select="$oUser" mode="member-userbar" />
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	
	<!-- Лого -->
	<xsl:template name="logo">
		<div class="logo">
			<a href="{$baseURI}/">
				<img src="{$baseURI}/images/logo.png" alt="Explay CMS Demo" />
			</a>
		</div>
	</xsl:template>	
	
	
	<!-- Блоки по-умолчанию -->
	<xsl:template name="default-blocks-top">
		<!--div>
			<xsl:apply-templates select="document('xmodule://banners/get/all;block')/data/response" mode="banners" />
		</div-->
	</xsl:template>
	<xsl:template name="default-blocks-bottom" />
	
	<!-- Footer -->
	<xsl:template name="footer">
		<div class="page-footer">
			<div class="copyright">
				<i>Работает на <a href="http://explay.su">Explay CMS</a></i>
			</div>
			<div class="menu">
				<xsl:if test="$userGroup = 'guest'">
					<dl>
						<dt>Авторизация</dt>
						<dd>
							<a href="{$baseURI}/users/login">Войти</a>
						</dd>
						<dd>
							<a href="{$baseURI}/users/registration">Зарегистрироваться</a>
						</dd>
						<dd>
							<a href="{$baseURI}/users/forgot">Забыли пароль?</a>
						</dd>
					</dl>
				</xsl:if>
				
				<xsl:if test="$userGroup != 'guest'">
					<xsl:apply-templates select="document(concat('xobject://user/', $userId))/data/object" mode="member-footer-menu" />
				</xsl:if>
				<dl>
					<dt>Разделы</dt>
					<dd>
						<a href="{$baseURI}/blogs">Блоги</a>
					</dd>
					<dd>
						<a href="{$baseURI}/people">Люди</a>
					</dd>
					<dd>
						<a href="{$baseURI}/photos">Фото</a>
					</dd>
					<dd>
						<a href="{$baseURI}/lenta">Лента</a>
					</dd>
					<dd>
						<a href="{$baseURI}/comments">Комментарии</a>
					</dd>
				</dl>
				<dl>
					<dt>Записи в блогах</dt>
					<dd>
						<a href="{$baseURI}/">Популярные</a>
					</dd>
					<dd>
						<a href="{$baseURI}/blogs/all">Все</a>
					</dd>
					<dd>
						<a href="{$baseURI}/blogs/thematic">Тематические</a>
					</dd>
					<dd>
						<a href="{$baseURI}/blogs/personal">Персональные</a>
					</dd>
					<dd>
						<a href="{$baseURI}/blogs/top">Рейтинг блогов</a>
					</dd>
				</dl>
				<dl>
					<dt>Информация</dt>
					<dd>
						<a href="{$baseURI}/page/about">О сайте</a>
					</dd>
					<dd>
						<a href="{$baseURI}/page/contacts">Контакты</a>
					</dd>
				</dl>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='user']" mode="member-footer-menu">
		<xsl:param name="login" select="property[@name='login']/value" />
		
		<dl>
			<dt>
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="property[@name='name']/value" />
				</a>
			</dt>
			<dd>
				<a href="{$baseURI}/blogs/user/{$login}">Мой блог</a>
			</dd>
			<dd>
				<a href="{$baseURI}/mail">Сообщения</a>
			</dd>
			<dd>
				<a href="{$baseURI}/users/edit_profile">Настройки</a>
			</dd>
			<dd>
				<a href="{$baseURI}/users/logout">Выход</a>
			</dd>
		</dl>
	</xsl:template>
	
	<!-- Сообщение -->
	<xsl:template match="message">
		<div class="system-message"><xsl:value-of select="." /></div>
	</xsl:template>
	
	<!-- Сообщение об ошибке -->
	<xsl:template match="error">
		<div class="system-error"><xsl:value-of select="." /></div>
	</xsl:template>
	
	<xsl:template match="object[@type='user']" mode="member-userbar">
		<xsl:param name="login" select="property[@name='login']/value" />
		<xsl:param name="avatar" select="property[@name='avatar']/value" />
		
		<div class="user">
			<div class="avatar">
				<a href="{$baseURI}/user/{$login}">
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-avatar-small.png" alt="{$login}" />
					</xsl:if>
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_24_24{$avatar}" alt="{$login}" />
					</xsl:if>
				</a>
			</div>
			<div class="name">
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="$login" />
				</a>
			</div>
		</div>
		
		<div class="controls">
			<div class="controls-inner">
				<a class="settings" href="{$baseURI}/users/edit_profile">настройки</a>
				<a class="messages" href="{$baseURI}/mail">почта (<xsl:value-of select="document('xmodule://mail/getCountNewMessages')/data/response/count/value" />)</a>
				<a class="blog" href="{$baseURI}/blogs/user/{$login}">мой блог</a>
				<div class="add">
					<ul class="sub" id="userbar_menu">
						<li>
							<a href="{$baseURI}/blogs/add/article">Запись в блог</a>
						</li>
						<li>
							<a href="{$baseURI}/photos/upload">Фотографию</a>
						</li>
						<li class="separator">
							<a href="{$baseURI}/mail/write">Написать другу</a>
						</li>
						<li>
							<a href="{$baseURI}/blogs/create_blog">Создать блог</a>
						</li>
						<li>
							<a href="{$baseURI}/photos/create_album">Создать фотоальбом</a>
						</li>
					</ul>
					
					<a class="link" href="#" onclick="this.blur(); Userbar.menu(); return false;"><span>добавить</span></a>
				</div>
				<a class="logout" href="{$baseURI}/users/logout">выход</a>
			</div>
		</div>
		
		<div class="micro">
			<div class="help-bar" id="micro_bar">
				<h3>Справка</h3>
				<p>Используйте метки, начинающиеся с символа # (например, #nowplaying), для добавления сообщения в определенный поток.</p>
			</div>
			
			<form action="" method="post" id="micro_form">
				<div class="input-border-vertical">
					<div class="input-border-horisontal">
						<div class="input">
							<input class="message" id="micro_text" type="text" name="micro" value="" autocomplete="off" maxlength="255" />
							<button class="submit" id="micro_submit" type="submit" name="done">•</button>
							<div class="label" id="micro_label" />
						</div>
					</div>
				</div>
			</form>
				
			<div class="more">
				<a href="#" onclick="this.blur(); Micro.bar(); return false;">?</a>
			</div>
		</div>
	</xsl:template>

</xsl:stylesheet>